package org.atguigu.gmall.realtime.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * Project:gmallRealTime
 * Package:org.atguigu.gmall.realtime.util
 * Author: ZengHaiFeng
 * CreateTime:2023/5/4 21:01:06
 * Description: Todo
 * Version：1.0
 */
public class RedisUtil {
    private static final JedisPool pool;
    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(300);
        config.setMaxIdle(10);
        config.setMinIdle(2);
        config.setMaxWaitMillis(10*1000);
        config.setTestOnCreate(true);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);

        pool = new JedisPool(config,"hadoop162",6379);
    }
    public static Jedis getRedisClient() {
        Jedis jedis = pool.getResource();
        jedis.select(4);
        return jedis;
    }
}
